package wiki.douzi.helpyougrow.service.impl;

import wiki.douzi.helpyougrow.domain.GoodsCategory;
import wiki.douzi.helpyougrow.mapper.GoodsCategoryMapper;
import wiki.douzi.helpyougrow.service.GoodsCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;
import javax.annotation.Resource;

/**
 * (GoodsCategory)表服务实现类
 *
 * @author Douzi
 * @since 2022-06-18 16:39:17
 */
@Service("goodsCategoryService")
public class GoodsCategoryServiceImpl implements GoodsCategoryService {
    @Resource
    private GoodsCategoryMapper goodsCategoryMapper;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @Override
    public List<GoodsCategory> queryAll() {
        return this.goodsCategoryMapper.queryAll();
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public GoodsCategory queryById(Integer id) {
        return this.goodsCategoryMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param goodsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsCategory insert(GoodsCategory goodsCategory) {
        this.goodsCategoryMapper.insert(goodsCategory);
        return goodsCategory;
    }

    /**
     * 修改数据
     *
     * @param goodsCategory 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsCategory update(GoodsCategory goodsCategory) {
        this.goodsCategoryMapper.update(goodsCategory);
        return this.queryById(goodsCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.goodsCategoryMapper.deleteById(id) > 0;
    }
}

